#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

// Q1. 选择不同 X 值三元组使 Y 值之和最大
// https://leetcode.cn/contest/biweekly-contest-158/problems/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues/description/

class Solution {
public:
    int maxSumDistinctTriplet(vector<int>& x, vector<int>& y) {
        unordered_map<int, int> xMap;
        unordered_set<int> deletey;
        vector<int> standardNum;
        for (int i = 0; i < x.size(); i++)
        {
            int curNum = x[i];
            if (xMap.find(curNum) != xMap.end())
            {
                if(y[xMap[curNum]] < y[i]){
                    deletey.insert(xMap[curNum]);
                    xMap[curNum] = i;
                }
                else
                {
                    deletey.insert(i);
                }
            }else{
                xMap[curNum] = i;
            }
        }
        if(xMap.size() < 3){
            return -1;
        }
        for (int i = 0; i < y.size(); i++){
            if(deletey.find(i) == deletey.end()){
                standardNum.push_back(y[i]);
                continue;
            }
        }
        sort(standardNum.begin(), standardNum.end(), std::greater<int>());
        return standardNum[0] + standardNum[1] + standardNum[2];
    }
};

int main()
{
    return 0;
}